package com.sc.nft.admin.controller;

import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.dto.ApplicationRequirementAddDTO;
import com.sc.nft.entity.dto.ApplicationRequirementSelectListDTO;
import com.sc.nft.entity.dto.ApplicationRequirementUpdateDTO;
import com.sc.nft.entity.vo.ApplicationRequirementAdminExotheciumVO;
import com.sc.nft.entity.vo.ApplicationRequirementSelectListVO;
import com.sc.nft.entity.vo.TotalPerformanceVO;
import com.sc.nft.entity.vo.WebApplicationRequirementVO;
import com.sc.nft.service.ApplicationRequirementService;
import com.sc.nft.service.ServiceCenterAuditService;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * (ApplicationRequirement)表控制层
 *
 * @author wwc
 * @since 2023-07-18 16:19:55
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/applicationRequirement")
@Api(tags = "")
public class ApplicationRequirementController {

    /**
     * 服务对象
     */
    private final ApplicationRequirementService applicationRequirementService;

    private final ServiceCenterAuditService serviceCenterAuditService;


    @PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "新增", notes = "新增", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result add(@Validated @RequestBody List<ApplicationRequirementAddDTO> applicationRequirementAddDTO) {
        applicationRequirementService.add(applicationRequirementAddDTO);
        return Result.success();
    }


    @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "修改", notes = "修改", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result update(@Validated @RequestBody List<ApplicationRequirementUpdateDTO> applicationRequirementUpdateDTOS) {
        applicationRequirementService.updates(applicationRequirementUpdateDTOS);
        return Result.success();
    }

    @PostMapping(value = "/selectList", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "获取对应类型的所以数据", notes = "获取对应类型的所以数据", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<List<ApplicationRequirementAdminExotheciumVO>>selectList(@RequestBody ApplicationRequirementSelectListDTO applicationRequirementSelectListDTO ) {
        return Result.success(applicationRequirementService.selectList(applicationRequirementSelectListDTO.getServeType()));
    }

    @PostMapping(value = "/performance", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "业绩", notes = "业绩", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<WebApplicationRequirementVO> totalPerformance(@RequestBody IdRequest idRequest) {
        return Result.success(serviceCenterAuditService.totalPerformance(idRequest.getId()));
    }
}
